<template>
    <div v-loading="loading" class="data-content">
        <el-table :data="resultList" border style="width: 100%">
            <el-table-column label="企业名称" prop="deptname" width="200" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="deptcode" label="统一社会信用代码" width="200">
            </el-table-column>
            <el-table-column label="法定代表人" prop="chargeman" width="100">
            </el-table-column>

            <el-table-column label="认定部门" prop="commitdept" width="150">
            </el-table-column>
            <el-table-column label="类型" prop="type" width="150">
            </el-table-column>
            <el-table-column label="事由" prop="reason">
            </el-table-column>
        </el-table>
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[10, 15, 20]" :page-size="size"
            layout="total, sizes, prev, pager, next" style="text-align:right; margin-top:1em;" :total="total">
        </el-pagination>

        <el-link v-if="resultList.length > 0" type="info" :underline="false">*此数据来源于军队采购官方网站</el-link>

        <div v-else>
            <div class="nodata">
                <img :src="imgUrl" alt="" />
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        companyName: {
            type: String,
            default: '',
        },
        projectId: {
            type: String,
            default: '',
        },
        navName: {
            type: String,
            default: '',
        },
    },
    data: () => ({
        contentText: {},
        resultList: [],
        current: 1,
        size: 10,
        total: null,
        imgUrl: require('../../img/wu.png'),
        loading: false,
    }),
    methods: {
        handleSizeChange: function (pageSize) {
            this.size = pageSize;
            this.getQiYeInfo();
        },
        handleCurrentChange: function (pageNum) {
            this.current = pageNum;
            this.getQiYeInfo();
        },

        //获取企业基本信息
        getQiYeInfo() {
            var that = this;
            this.loading = true;

            let dataList = {
                corpName: that.companyName,
                projectId: that.projectId,
                page: {
                    current: this.current,
                    size: this.size,
                },
            };

            this.$post(
                `${this.$store.state.api.searchUrl}/searchblack/blacklist`,
                dataList,
                (data) => {
                    // if (!!data.entitys) {
                    // that.contentText = data.rows[0];
                    this.resultList = data.rows;
                    that.total = data.total;
                    that.$emit('pushValidNames', that.navName);
                    // }
                    this.loading = false;
                },
                true
            );
        },
    },
    watch: {
        companyName() {
            this.getQiYeInfo();
        },
    },
    mounted() {
        this.getQiYeInfo();
    },
};
</script>

<style scoped lang="scss">
.data-content {
    // border-bottom: 1px solid #efefef;
    width: 100%;
    min-height: 400px;
    padding: 10px 15px;
}
.nodata {
    width: 30%;
    margin: 20px auto;
}
::v-deep th {
    width: 250px;
}
</style>
